package br.gov.mi.corporativo.dominio.boundary.comum.uf;

import java.util.List;

import javax.inject.Inject;
import javax.jws.WebService;

import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import br.gov.mi.corporativo.dominio.entidade.comum.Uf;
import br.gov.mi.corporativo.dominio.repositorio.comum.UfRepositorio;
import br.gov.mi.infraestrutura.crud.CrudServicoImpl;

@Component
@Transactional(readOnly=true)
@WebService(endpointInterface = "br.gov.mi.corporativo.dominio.boundary.comum.uf.UfEndPoint")
public class UfServico extends CrudServicoImpl<Uf, Long, UfRepositorio>  implements UfEndPoint{
	
    @Inject
    public void setRepository(UfRepositorio repositorio) {
        super.setRepositorio(repositorio);
    }

    
    @Override
    public List<Uf> recuperarTodos() {
    	return repositorio.findAll(new Sort(Direction.ASC,"strNomeuf"));
    }
	public Uf recuperarPorSigla(String sigla) {
		return repositorio.findByStrSiglauf(sigla);
	}

	public Uf recuperarPorNome(String nome) {
		return repositorio.findByStrNomeuf(nome);
	}	
	
}
